﻿using UnityEngine;
using System.Collections;
using iTManager;
public class Levels : MonoBehaviour {
	[SerializeField]
	private GameObject[] objects;
	private Vector3 old_position;
	private OpenDialog levels;
	private CloseDialog close;
    [SerializeField]
    private AudioClip soundClip;
    private GameManager manager;

	void Start () {
		old_position=objects[1].transform.position;
		levels=new OpenDialog(objects);
		close=new CloseDialog(objects,old_position);
        manager = GameManager.getInstance();

        
	}	
	private void levelClick(){
        if (manager.Sound)
        { PlaySound(); }
        levels.Action();

		
	}
	private void CloseClick(){
        if (manager.Sound)
        { PlaySound(); }
        StartCoroutine(loadNextScene());
		close.Action();
        
	}
    private void BackToMab()
    {
        close.Action();
        Application.LoadLevel(2);
    }
    void PlaySound()
    {
        audio.clip = soundClip;
        audio.Play();
    }
    private IEnumerator loadNextScene()
    {
        yield return new WaitForSeconds(1f);
        //new Invoker(new Play(2)).Execute();
    }
}
